import os
import sys
import time
import json
import django
import uuid

BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
print(os.path.abspath(__file__))
print(BASE_DIR)
sys.path.extend([BASE_DIR, ])
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "finance_c2c.settings")
django.setup()

from apps.user_operation.models import UserProfile
from django.contrib.auth import get_user_model
from apps.coffee.models import Channel

UserModel = get_user_model()


def update_password(mobile):
    instance = UserProfile.objects.get(mobile=mobile)
    instance.set_password("123456")
    instance.save()


def create_user(mobile):
    channel = Channel.objects.get(key=mobile)
    UserModel.objects.create(
        mobile=mobile,
        username=mobile,
        can_transfer=False,
        coffee_channel=channel,
        is_coffee_manager=True,
        coffee_new_user=False,
        can_share_coupon=False
    )


if __name__ == '__main__':
    # update_password()
    # create_user("meitandasha")
    update_password("13811819611")
    pass
